<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="PersonneListForm">

        <p:panel header="#{bundle.ListPersonneTitle}">

            <p:dataTable id="datalist" value="#{personneController.items}" var="item"
                         selectionMode="single" selection="#{personneController.selected}"
                         rowKey="#{item.idPersonne}"
                         paginator="true"
                         rows="5"
                         rowsPerPageTemplate="5,10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.idPersonne}" filterBy="#{item.idPersonne}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_idPersonne}"/>
                    </f:facet>
                    <h:outputText value="#{item.idPersonne}"/>
                </p:column>
                <p:column sortBy="#{item.cin}" filterBy="#{item.cin}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_cin}"/>
                    </f:facet>
                    <h:outputText value="#{item.cin}"/>
                </p:column>
                <p:column sortBy="#{item.nom}" filterBy="#{item.nom}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_nom}"/>
                    </f:facet>
                    <h:outputText value="#{item.nom}"/>
                </p:column>
                <p:column sortBy="#{item.prenom}" filterBy="#{item.prenom}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_prenom}"/>
                    </f:facet>
                    <h:outputText value="#{item.prenom}"/>
                </p:column>
                <p:column sortBy="#{item.sexe}" filterBy="#{item.sexe}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_sexe}"/>
                    </f:facet>
                    <h:outputText value="#{item.sexe}"/>
                </p:column>
                <p:column sortBy="#{item.dateNaissance}" filterBy="#{item.dateNaissance}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_dateNaissance}"/>
                    </f:facet>
                    <h:outputText value="#{item.dateNaissance}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>
                
                <p:column sortBy="#{item.telephone1}" filterBy="#{item.telephone1}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonneTitle_telephone1}"/>
                    </f:facet>
                    <h:outputText value="#{item.telephone1}"/>
                </p:column>
                
             
                <f:facet name="footer">
                    <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{personneController.prepareCreate}" update=":PersonneCreateForm" oncomplete="PersonneCreateDialog.show()"/>
                    <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" update=":PersonneViewForm" oncomplete="PersonneViewDialog.show()" disabled="#{empty personneController.selected}"/>
                    <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":PersonneEditForm" oncomplete="PersonneEditDialog.show()" disabled="#{empty personneController.selected}"/>
                    <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}"   actionListener="#{personneController.delete}" update=":growl,datalist" disabled="#{empty personneController.selected}"/>
                </f:facet>

            </p:dataTable>
            <p:confirmDialog id="confirmDialog" modal="true" resizable="false" appendToBody="true" message="Voulez - vous vraiment supprimer cette personne ?"
			header="Suppression personne : " severity="alert"  widgetVar="confirmation">
			<p:commandButton id="confirm" value="#{bundle.Delete}"  oncomplete="confirmation.hide()" actionListener="#{personneController.delete}" update=":growl,datalist" />
		<p:commandButton id="decline" value="Annuler" onclick="confirmation.hide()" type="button" /> 
	   </p:confirmDialog>
        </p:panel>

    </h:form>

</ui:composition>